package com.biostime.qdingding.modules.sys.entity;

import java.util.Date;
import java.util.List;

import com.biostime.qdingding.common.persistence.DataEntity;
import com.biostime.qdingding.modules.qd.entity.Center;
import com.google.common.collect.Lists;

/**
 * 用户表Entity
 * @author phil
 * @version 2015-11-03
 */
public class User extends DataEntity<User> {

	private static final long serialVersionUID = 1L;
	
	private String loginName;// 登录名
	private String password;// 密码
	private String no;// 工号
	private String name;// 姓名
	private String email;// 邮箱
	private String phone;// 电话
	private String mobile;// 手机
	private String userType;// 用户类型
	private String avatar;// 用户头像
	private String loginIp;// 最后登陆IP
	private Date loginDate;// 最后登陆时间
	private String loginFlag;// 是否可登录
	
	private Center center;// 用户最近登录中心
	
	private List<Role> roles = Lists.newArrayList(); // 用户角色
	private List<Center> centers = Lists.newArrayList(); // 用户所有早教中心
	
	//private List<Role> roleList; // 用户角色
	//private List<Center> centerList;// 用户所有早教中心
	
	public User(){
		
	}
	
	public User(String id){
		setId(id);
	}
	
	public User(String id, String loginName){
		super(id);
		this.loginName = loginName;
	}
	
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}
	
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public String getUserType() {
		return userType;
	}

	public void setUserType(String userType) {
		this.userType = userType;
	}
	
	public String getLoginIp() {
		return loginIp;
	}

	public void setLoginIp(String loginIp) {
		this.loginIp = loginIp;
	}
	
	public Date getLoginDate() {
		return loginDate;
	}

	public void setLoginDate(Date loginDate) {
		this.loginDate = loginDate;
	}
	
	public String getLoginFlag() {
		return loginFlag;
	}

	public void setLoginFlag(String loginFlag) {
		this.loginFlag = loginFlag;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public Center getCenter() {
		return center;
	}

	public void setCenter(Center center) {
		this.center = center;
	}
	
	/*public void setRoleList(List<Role> roleList) {
		this.roleList = roleList;
	}

	public List<Role> getRoleList() {
		return roleList;
	}

	public List<Center> getCenterList() {
		return centerList;
	}

	public void setCenterList(List<Center> centerList) {
		this.centerList = centerList;
	}*/
	
	/**自定义方法**/
	public boolean isAdmin(){
		return isAdmin(this.id);
	}
	
	public static boolean isAdmin(String id){
		return id != null && "1".equals(id);
	}
	/**自定义方法**/

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public List<Center> getCenters() {
		return centers;
	}

	public void setCenters(List<Center> centers) {
		this.centers = centers;
	}
}